package com.code.Day12Meiju.YiChang.KongZZ;

import java.util.Objects;

public class Dome03 {
    String name;
    int age;

    public Dome03() {

    }

    public Dome03(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }


//    重写toString

//    public String toString(){
//        return name+age;
//    }


    @Override
    public String toString() {
        return "Dome03{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

//    public boolean equals(Object obj) {
//    if(obj ==null){
//        return false;
//    }
//        if (obj instanceof Dome03) {
//            Dome03 d = (Dome03) obj;
//            return this.name.equals(d.name) && this.age == d.age;
//        }
//        return false;
//
//    }


    @Override
    public boolean equals(Object object) {
        if (object == null || getClass() != object.getClass()) return false;
        Dome03 dome03 = (Dome03) object;
        return age == dome03.age && Objects.equals(name, dome03.name);
    }


}
